package dpir

import(
	"unsafe"
)


func Float32ToBytes(f32 float32)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&f32)), 4)
}


func Float64ToBytes(f64 float64)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&f64)), 8)
}


func BytesToFloat32(byts []byte)float32{
  return *(*float32)(unsafe.Pointer(&byts[0]))
}


func BytesToFloat64(byts []byte)float64{
  return *(*float64)(unsafe.Pointer(&byts[0]))
}


func Int8ToByte(i8 int8) byte{
  return byte(i8)
}


func Int16ToBytes(i16 int16) []byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&i16)), 2)
}


func Int32ToBytes(i32 int32)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&i32)), 4)
}


func Int64ToBytes(i64 int64)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&i64)), 8)
}


func ByteToInt8(b8 byte)int8{
  return int8(uint8(b8))
}


func BytesToInt16(b16 []byte)int16{
  return *(*int16)(unsafe.Pointer(&b16[0]))
}


func BytesToInt32(b32 []byte)int32{
  return *(*int32)(unsafe.Pointer(&b32[0]))
}


func BytesToInt64(b64 []byte)int64{
  return *(*int64)(unsafe.Pointer(&b64[0]))
}


func Uint16ToBytes(ui16 uint16)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&ui16)), 2)
}


func Uint32ToBytes(ui32 uint32)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&ui32)), 4)
}


func Uint64ToBytes(ui64 uint64) []byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&ui64)), 8)
}


func BytesToUint16(b16 []byte)uint16{
  return *(*uint16)(unsafe.Pointer(&b16[0]))
}


func BytesToUint32(b32 []byte)uint32{
  return *(*uint32)(unsafe.Pointer(&b32[0]))
}


func BytesToUint64(b64 []byte)uint64{
  return *(*uint64)(unsafe.Pointer(&b64[0]))
}


func Complex64ToBytes(plx64 complex64)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&plx64)), 8)
}


func Complex128ToBytes(plx128 complex128)[]byte{
  return unsafe.Slice((*byte)(unsafe.Pointer(&plx128)), 16)
}


func BytesToComplex64(b64 []byte)complex64{
  return *(*complex64)(unsafe.Pointer(&b64[0]))
}


func BytesToComplex128(b128 []byte)complex128{
  return *(*complex128)(unsafe.Pointer(&b128[0]))
}